
//- This Source Code Form is subject to the terms of the Mozilla Public
//- License, v. 2.0. If a copy of the MPL was not distributed with this
//- file, You can obtain one at http://mozilla.org/MPL/2.0/.
//-
//- Copyright (c) 2021-present Kaleidos Ventures SL

div.assigned-inline
    div(ng-if="isAssigned")
        .user-list(ng-if="assignedUsers.length > 1")
            .user-list-item(ng-repeat="assignedUser in assignedUsers")
                img(
                    tg-avatar="assignedUser"
                    title="{{assignedUser.full_name_display}}"
                    alt="{{assignedUser.full_name_display}}"
                )
            .user-list-item.counter(ng-if="hiddenUsers")
                span +{{ hiddenUsers }}


        .ticket-user-list(ng-if="assignedUsers.length == 1")
            .user-list-single
                .user-list-avatar
                    img(
                        tg-avatar="assignedUsers[0]"
                        title="{{assignedUsers[0].full_name_display}}"
                        alt="{{assignedUsers[0].full_name_display}}"
                    )
                .user-list-name
                    span {{ assignedUsers[0].full_name_display }}
                tg-svg.remove-user(
                    svg-icon="icon-close",
                    title="{{'COMMON.ASSIGNED_TO.DELETE_ASSIGNMENT' | translate}}"
                    ng-click="unassign(assignedUsers[0])"
                )

        div.add-assigned
            a.users-dropdown.tg-add-assigned(
                href=""
            )
                tg-svg.add-assigned(
                    data-assigned-user-id="{{assignedUser.id}}",
                    svg-icon="icon-add",
                    title="{{'COMMON.ASSIGNED_USERS.ADD_ASSIGNED' | translate}}"
                )
                span {{ "COMMON.ASSIGNED_USERS.ADD_ASSIGNED" | translate }}


    .ticket-user-list(ng-if="!isAssigned")
        .user-list-single
            .user-list-avatar
                img(
                    tg-avatar=""
                    alt="{{ 'COMMON.ASSIGNED_TO.ASSIGN' | translate }}"
                )
            .user-list-name
                a.users-dropdown.user-assigned(
                    href=""
                    title="{{ 'COMMON.ASSIGNED_TO.TITLE_ACTION_EDIT_ASSIGNMENT'|translate }}"
                )
                    span.assigned-name {{ "COMMON.ASSIGNED_TO.ASSIGN" | translate }}
                | &nbsp;
                span.read-only(translate="COMMON.OR")
                | &nbsp;
                a.self-assign(
                    href="#"
                    ng-click="selfAssign()"
                    title="{{'COMMON.ASSIGNED_TO.SELF' | translate}}"
                )
                    span {{ "COMMON.ASSIGNED_TO.SELF" | translate }}

    div.pop-users.popover(ng-class="{'multiple': assignedUsers.length > 0}")
        input.users-search(
            type="text"
            data-maxlength="500"
            placeholder="{{'LIGHTBOX.ASSIGNED_TO.SEARCH' | translate}}"
            ng-model="usersSearch"
        )
        a.user-list-single.selected(
            href=""
            data-user-id="{{ user.id }}"
            title="{{ user.full_name_display }}"
            ng-repeat="user in selected"
            ng-class="{'selected': selected.indexOf(user) == -1 }"
        )
            img.user-list-avatar(
                style="background: {{user.avatar.bg }}"
                src="{{ user.avatar.url }}"
            )
            span.user-list-name(
                href=""
                title="{{ user.full_name_display }}"
            ) {{ user.full_name_display }}
            tg-svg.remove(
                href=""
                ng-click="unassign(user)"
                ng-if="selected.indexOf(user) > -1"
                svg-icon="icon-close",
                title="{{'COMMON.ASSIGNED_TO.DELETE_ASSIGNMENT' | translate}}"
            )

        a.user-list-single(
            href=""
            data-user-id="{{ user.id }}"
            title="{{ user.full_name_display }}"
            ng-repeat="user in users"
            ng-click="assign(user)"
        )
            img.user-list-avatar(
                style="background: {{user.avatar.bg }}"
                src="{{ user.avatar.url }}"
            )
            span.user-list-name(
                href=""
                title="{{ user.full_name_display }}"
            ) {{ user.full_name_display }}
            tg-svg.remove(
                href=""
                data-user-id="{{ user.id }}"
                ng-if="selected.indexOf(user) > -1"
                svg-icon="icon-close",
                title="{{'COMMON.ASSIGNED_TO.DELETE_ASSIGNMENT' | translate}}"
            )

        .show-more(ng-if="showMore")
            span(translate="COMMON.ASSIGNED_TO.TOO_MANY")